function trim(str) {    
    if (typeof str === 'undefined' || str == null) {
        return '';
    }
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function fieldIsInt(field) {
    return (field.value && 
    		/^\d+$/.test(field.value) && 
    		0 < field.value &&
    		isFinite(field.value));
}

function fieldExists(field) {
	typeof field !== 'undefinded';
}

function isBlank(field) {
	return !field.value || /^\s*$/.test(field.value);
}

function fieldLengthBetween (field, min_length, max_length) {
	if (min_length !== null && field.value.length < min_length) {
		return false;
	}
	if (max_length !== null && field.value.length > max_length) {
		return false;
	}
	return true;
}